import request from '@/config/axios'
import {
  ContentCategoryListParams,
  ContentCategoryListResponse,
  ContentCategoryItem,
  ContentListParams,
  ContentListResponse,
  ContentItem
} from './types'

// 学院分类列表
export const contentCategoryListApi = (params: ContentCategoryListParams) => {
  return request.get<ContentCategoryListResponse>({ url: '/contentCategory/page', params })
}

// 保存学院分类
export const contentCategorySaveApi = (data: ContentCategoryItem) => {
  return request.post({ url: '/contentCategory/save', data })
}

// 更新学院分类
export const contentCategoryUpdateApi = (data: ContentCategoryItem) => {
  return request.post({ url: '/contentCategory/update', data })
}

// 删除学院分类
export const contentCategoryDeleteApi = (id: number) => {
  return request.post({ url: `/contentCategory/delete?id=${id}` })
}

// 学院文章列表
export const contentListApi = (params: ContentListParams) => {
  return request.get<ContentListResponse>({ url: '/content/page', params })
}

// 保存学院文章
export const contentSaveApi = (data: ContentItem) => {
  return request.post({ url: '/content/save', data })
}

// 更新学院文章
export const contentUpdateApi = (data: ContentItem) => {
  return request.post({ url: '/content/update', data })
}

// 删除学院文章
export const contentDeleteApi = (id: number) => {
  return request.post({ url: `/content/delete?id=${id}` })
}

// 上下架学院文章
export const contentUpdateStateApi = (data: any) => {
  return request.post({ url: '/content/updateState', data })
}
